<script lang="ts">
import { useRoute, useRouter } from 'vue-router';

export default defineComponent({
  name: 'Redirect',
  setup() {
    const route = useRoute();
    const router = useRouter();
    onBeforeMount(() => {
      const { params, query: rawQuery } = route;
      const { path } = params;
      let query = {
        ...rawQuery,
      };
      if (path.includes('?')) {
        query = {
          ...query,
          ...Object.fromEntries(new URLSearchParams(path.split('?')[1]).entries()),
        };
      }
      router.replace({
        path: Array.isArray(path) ? path.join('/') : path,
        query,
      });
    });
  },
});
</script>

<template>
  <div>
    <AEmpty />
  </div>
</template>
